/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package communication.impl;

import communication.CommunicationPackage;
import communication.RestFulService;
import communication.ServiceCommunicator;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Service Communicator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link communication.impl.ServiceCommunicatorImpl#getName <em>Name</em>}</li>
 *   <li>{@link communication.impl.ServiceCommunicatorImpl#getTimeout <em>Timeout</em>}</li>
 *   <li>{@link communication.impl.ServiceCommunicatorImpl#getUseServices <em>Use Services</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ServiceCommunicatorImpl extends EObjectImpl implements ServiceCommunicator {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getTimeout() <em>Timeout</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeout()
	 * @generated
	 * @ordered
	 */
	protected static final int TIMEOUT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getTimeout() <em>Timeout</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeout()
	 * @generated
	 * @ordered
	 */
	protected int timeout = TIMEOUT_EDEFAULT;

	/**
	 * The cached value of the '{@link #getUseServices() <em>Use Services</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUseServices()
	 * @generated
	 * @ordered
	 */
	protected RestFulService useServices;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ServiceCommunicatorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CommunicationPackage.Literals.SERVICE_COMMUNICATOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.SERVICE_COMMUNICATOR__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getTimeout() {
		return timeout;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeout(int newTimeout) {
		int oldTimeout = timeout;
		timeout = newTimeout;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.SERVICE_COMMUNICATOR__TIMEOUT, oldTimeout, timeout));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RestFulService getUseServices() {
		if (useServices != null && useServices.eIsProxy()) {
			InternalEObject oldUseServices = (InternalEObject)useServices;
			useServices = (RestFulService)eResolveProxy(oldUseServices);
			if (useServices != oldUseServices) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES, oldUseServices, useServices));
			}
		}
		return useServices;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RestFulService basicGetUseServices() {
		return useServices;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUseServices(RestFulService newUseServices) {
		RestFulService oldUseServices = useServices;
		useServices = newUseServices;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES, oldUseServices, useServices));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CommunicationPackage.SERVICE_COMMUNICATOR__NAME:
				return getName();
			case CommunicationPackage.SERVICE_COMMUNICATOR__TIMEOUT:
				return getTimeout();
			case CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES:
				if (resolve) return getUseServices();
				return basicGetUseServices();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CommunicationPackage.SERVICE_COMMUNICATOR__NAME:
				setName((String)newValue);
				return;
			case CommunicationPackage.SERVICE_COMMUNICATOR__TIMEOUT:
				setTimeout((Integer)newValue);
				return;
			case CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES:
				setUseServices((RestFulService)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CommunicationPackage.SERVICE_COMMUNICATOR__NAME:
				setName(NAME_EDEFAULT);
				return;
			case CommunicationPackage.SERVICE_COMMUNICATOR__TIMEOUT:
				setTimeout(TIMEOUT_EDEFAULT);
				return;
			case CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES:
				setUseServices((RestFulService)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CommunicationPackage.SERVICE_COMMUNICATOR__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case CommunicationPackage.SERVICE_COMMUNICATOR__TIMEOUT:
				return timeout != TIMEOUT_EDEFAULT;
			case CommunicationPackage.SERVICE_COMMUNICATOR__USE_SERVICES:
				return useServices != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", timeout: ");
		result.append(timeout);
		result.append(')');
		return result.toString();
	}

} //ServiceCommunicatorImpl
